package gof.com.yew.chainOfRes;

public abstract class AbstractLogger {
	
	protected static int INFO = 1;
	protected static int DEBUG = 2;
	protected static int ERROR = 3;
	
	protected int level ;
	
	protected AbstractLogger nextLogger;

	public void setNextLogger(AbstractLogger nextLogger) {
		this.nextLogger = nextLogger;
	}
	
	public void logMsg(int level,String msg) {
		System.out.println("---thisLevel="+this.level+"---level="+level);
		if(this.level == level) {
			write(msg);
		}else {
			if(nextLogger!=null) {
				nextLogger.logMsg(level, msg);
			}
		}
	}
	
	abstract  void write(String msg);

}
